﻿<Page
    x:Class="EmprestaAE.MVVM.View.LendView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:EmprestaAE.MVVM.View"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewmodel="using:EmprestaAE.MVVM.ViewModel"
    xmlns:view="using:EmprestaAE.MVVM.View"
    xmlns:converters="using:EmprestaAE.Common"
    xmlns:attached="using:EmprestaAE.Common.AttachedProperties"
    xmlns:controls="using:EmprestaAE.Common.Controls"
    xmlns:enums="using:EmprestaAE.Common.Enums"
    mc:Ignorable="d">
    <Page.Transitions>
        <TransitionCollection>
            <EntranceThemeTransition/>
        </TransitionCollection>
    </Page.Transitions>

    <Page.Resources>        
        <viewmodel:LendVM x:Key="lendvm"/>
        <converters:ConverterBoolToVisibility x:Key="BoolToVisibilityConverter"/>
        <converters:ConverterDateToString x:Key="DateToStringConverter"/>
    </Page.Resources>
    <Grid Background="{StaticResource PageLendBackgroundColor}"
          DataContext="{Binding Source={StaticResource lendvm}, Path=Instance}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="6*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <!-- back button -->
        <Grid Grid.Column="0" 
              Grid.Row="0">
            <Button Style="{StaticResource BackButtonStyle}"
                    Grid.Row="0"
                    Grid.Column="0"
                    Command="{Binding NavigationService.GoBackCommand}">
            </Button>
        </Grid>

        <!-- title -->
        <Grid Grid.Row="0"
              Grid.Column="1">
            <TextBlock Style="{StaticResource PageHeaderTextStyle}"
                       Text="{StaticResource LendViewTitle}"
                       Grid.Column="1"
                       Grid.Row="0"/>
        </Grid>

        <!--content-->
        <Grid Grid.Row="1"
              Grid.Column="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="8*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="10*"/>
            </Grid.ColumnDefinitions>

            <!-- buttons -->
            <Grid Grid.Column="0"
                  Grid.Row="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <!-- what selection-->
                <Grid Grid.Column="0"
                      Grid.Row="0"
                      Margin="0,0,4,4">
                    <Button x:Name="button_whatpicker" Style="{StaticResource S_ButtonPicker}"                        
                        Command="{Binding ActivateWhatInputCommand}"
                        CommandParameter="WhatInput"
                        attached:Images.NormalImage="/Resources/Images/emprestaae_camera.png"
                        attached:Images.PressedImage="/Resources/Images/emprestaae_camera_pressed.png"
                        attached:Images.ImageVisibility="{Binding WhatImagePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}">                        
                        <Grid x:Name="c">
                            <Image Source="{Binding WhatImage.Source}"
                               Width="{Binding ElementName=contentpresenter, Path=ActualHeight}"
                               Height="{Binding ElementName=contentpresenter,Path=ActualHeight}"
                       
                       HorizontalAlignment="Left"/>
                            <StackPanel Orientation="Horizontal"
                                    HorizontalAlignment="Right">
                                <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                       Text="isto"
                                       Visibility="{Binding WhatImagePickered, Converter={StaticResource BoolToVisibilityConverter}}"/>
                                <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                       Text="o que?"
                                       Visibility="{Binding WhatImagePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}"/>
                            </StackPanel>
                        </Grid>
                    </Button>

                </Grid>

                <!-- contact selection-->
                <Grid Grid.Column="0"
                  Grid.Row="1"
                  Margin="0,0,4,4">
                    <Button Style="{StaticResource S_ButtonPicker}"
                        Command="{Binding ActivatePersonInputCommand}"
                        CommandParameter="PersonInput"
                        attached:Images.NormalImage="/Resources/Images/emprestaae_user.png"
                        attached:Images.PressedImage="/Resources/Images/emprestaae_user_pressed.png"
                        attached:Images.ImageVisibility="{Binding ContactImagePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}">
                        <Grid>
                            <Image Source="{Binding ContactImage.Source}"
                       Stretch="Uniform"
                       HorizontalAlignment="Left"/>
                            <StackPanel Orientation="Horizontal"
                                    HorizontalAlignment="Right">
                                <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                   Text="{Binding ContactName}"
                                       Visibility="{Binding ContactImagePickered, Converter={StaticResource BoolToVisibilityConverter}}"/>
                                <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                       Visibility="{Binding ContactImagePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}"
                                   Text="pra quem?"/>
                            </StackPanel>
                        </Grid>
                    </Button>
                </Grid>

                <!-- until when selection-->
                <Grid Grid.Column="0"
                  Grid.Row="2"
                  Margin="0,0,4,4">
                    <Button Style="{StaticResource S_ButtonPicker}"
                        Command="{Binding ActivateUntilInputCommand}"
                        CommandParameter="UntilInput"
                        attached:Images.NormalImage="/Resources/Images/emprestaae_calendar.png"
                        attached:Images.PressedImage="/Resources/Images/emprestaae_calendar_pressed.png"
                        attached:Images.ImageVisibility="{Binding DatePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}">                        
                        <Grid>
                            <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                   Visibility="{Binding DatePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}"
                                   Text="até quando?"/>
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right">
                                <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                   Visibility="{Binding DatePickered, Converter={StaticResource BoolToVisibilityConverter}}"
                                   Text="até "/>
                                <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                   Visibility="{Binding DatePickered, Converter={StaticResource BoolToVisibilityConverter}}"
                                   Text="{Binding Date, Converter={StaticResource DateToStringConverter}}"/>
                            </StackPanel>
                        </Grid>
                    </Button>
                </Grid>

                <!-- confirm lend -->
                <!--<Grid Grid.Column="1"
                  Grid.Row="1" 
                  Margin="20">
                    <Button Style="{StaticResource S_ButtonPicker}"
                        IsEnabled="{Binding LendEnable}"
                        Command="{Binding LendCommand}"
                        HorizontalAlignment="Center"
                        attached:Images.NormalImage="/Resources/Images/emprestaae_oklend.png"
                        attached:Images.PressedImage="/Resources/Images/emprestaae_oklend_pressed.png">
                    </Button>
                </Grid>-->

            </Grid>

            <!--painel input / confirm-->
            <Grid Grid.Column="2"
                  Grid.Row="0"
                  Margin="0,0,10,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <!--painel input-->
                <Grid Grid.Column="0"
                      Grid.Row="0"
                      Grid.RowSpan="3">
                    <!--what input-->
                    <Grid Visibility="{Binding IsWhatInputing, Converter={StaticResource BoolToVisibilityConverter}}">
                        <Grid.Background>
                            <ImageBrush Stretch="Uniform" ImageSource="/resources/images/emprestaae_camera_pressed.png" Opacity="0.1"/>
                        </Grid.Background>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="take a pic or name what you are lending"
                                   TextWrapping="Wrap"
                                   Grid.Row="0"
                                   Margin="10"
                                   FontSize="42"
                                   Foreground="Black"/>

                        <Grid Grid.Row="1" Margin="20">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>                                
                            </Grid.ColumnDefinitions>
                            <Button Style="{StaticResource S_ButtonPicker}"                        
                        Command="{Binding CaptureWhatCommand}"                        
                        CommandParameter="{Binding RelativeSource={RelativeSource Self}}"                        
                        attached:Images.NormalImage="/Resources/Images/emprestaae_camera.png"
                        attached:Images.PressedImage="/Resources/Images/emprestaae_camera_pressed.png"
                        attached:Images.ImageVisibility="{Binding WhatImagePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}">
                                <Grid>
                                    <Image Source="{Binding WhatImage.Source}"
                               Width="{Binding ElementName=contentpresenter, Path=ActualHeight}"
                               Height="{Binding ElementName=contentpresenter,Path=ActualHeight}"
                       
                       HorizontalAlignment="Left"/>
                                    <StackPanel Orientation="Horizontal"
                                    HorizontalAlignment="Right">
                                        <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                       Text="isto"
                                       Visibility="{Binding WhatImagePickered, Converter={StaticResource BoolToVisibilityConverter}}"/>
                                        <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                       Text="take a pic ..."
                                       Visibility="{Binding WhatImagePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}"/>
                                    </StackPanel>
                                </Grid>
                            </Button>
                        </Grid>

                        <Grid Grid.Row="2" Margin="20">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>                                
                            </Grid.ColumnDefinitions>
                            
                            <Border Background="{StaticResource BackgroundButton}">
                                <Grid>                               
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Style="{StaticResource S_TextBlockButtonPicker}" Text="name ->"
                                               VerticalAlignment="Center"/>
                                    <TextBox Grid.Column="1"
                                             Margin="10,0,20,0"
                                             VerticalAlignment="Center"                                             
                                             />
                                </Grid>
                            </Border>
                        </Grid>
                        

                    </Grid>
                    <!--who input-->

                    <Grid Visibility="{Binding IsPersonInputing, Converter={StaticResource BoolToVisibilityConverter}}">
                        <Grid.Background>
                            <ImageBrush Stretch="Uniform" ImageSource="/resources/images/emprestaae_user_pressed.png" Opacity="0.1"/>
                        </Grid.Background>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="para quem você está emprestando?"
                                   TextWrapping="Wrap"
                                   Grid.Row="0"
                                   Margin="10"
                                   FontSize="42"
                                   Foreground="Black"/>

                        <Grid Grid.Row="1" Margin="20">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Button Style="{StaticResource S_ButtonPicker}"
                        Command="{Binding SelectContactCommand}"
                        CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
                        attached:Images.NormalImage="/Resources/Images/emprestaae_user.png"
                        attached:Images.PressedImage="/Resources/Images/emprestaae_user_pressed.png"
                        attached:Images.ImageVisibility="{Binding ContactImagePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}">
                                <Grid>
                                    <Image Source="{Binding ContactImage.Source}"
                       Stretch="Uniform"
                       HorizontalAlignment="Left"/>
                                    <StackPanel Orientation="Horizontal"
                                    HorizontalAlignment="Right">
                                        <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                   Text="{Binding ContactName}"
                                       Visibility="{Binding ContactImagePickered, Converter={StaticResource BoolToVisibilityConverter}}"/>
                                        <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                       Visibility="{Binding ContactImagePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}"
                                   Text="escolher dos contatos ..."/>
                                    </StackPanel>
                                </Grid>
                            </Button>
                        </Grid>

                        <Grid Grid.Row="2" Margin="20">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <Border Background="{StaticResource BackgroundButton}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Style="{StaticResource S_TextBlockButtonPicker}" Text="name ->"
                                               VerticalAlignment="Center"/>
                                    <TextBox Grid.Column="1"
                                             Margin="10,0,20,0"
                                             VerticalAlignment="Center"                                             
                                             />
                                </Grid>
                            </Border>
                        </Grid>


                    </Grid>
                    <!--until input-->
                    <Grid Visibility="{Binding IsUntilInputing, Converter={StaticResource BoolToVisibilityConverter}}">
                        <Grid.Background>
                            <ImageBrush Stretch="Uniform" ImageSource="/resources/images/emprestaae_calendar_pressed.png" Opacity="0.1"/>
                        </Grid.Background>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="até quando você está emprestando?"
                                   TextWrapping="Wrap"
                                   Grid.Row="0"
                                   Margin="10"
                                   FontSize="42"
                                   Foreground="Black"/>

                        <Grid Grid.Row="1" Margin="20">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Button Style="{StaticResource S_ButtonPicker}"
                        Command="{Binding NavigationService.NavigateCommand}"
                        attached:Images.NormalImage="/Resources/Images/emprestaae_calendar.png"
                        attached:Images.PressedImage="/Resources/Images/emprestaae_calendar_pressed.png"
                        attached:Images.ImageVisibility="{Binding DatePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}">
                                <Button.CommandParameter>
                                    <view:DatePickerView/>
                                </Button.CommandParameter>
                                <Grid>
                                    <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                   Visibility="{Binding DatePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}"
                                   Text="escolher data..."/>
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right">
                                        <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                   Visibility="{Binding DatePickered, Converter={StaticResource BoolToVisibilityConverter}}"
                                   Text="até "/>
                                        <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                   Visibility="{Binding DatePickered, Converter={StaticResource BoolToVisibilityConverter}}"
                                   Text="{Binding Date, Converter={StaticResource DateToStringConverter}}"/>
                                    </StackPanel>
                                </Grid>
                            </Button>
                        </Grid>

                        <Grid Grid.Row="2" Margin="20">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <Border Background="{StaticResource BackgroundButton}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Style="{StaticResource S_TextBlockButtonPicker}" Text="name ->"
                                               VerticalAlignment="Center"/>
                                    <TextBlock Style="{StaticResource S_TextBlockButtonPicker}" Text="name ->"
                                               HorizontalAlignment="Left"
                                               Grid.Column="1"/>
                                    
                                </Grid>
                            </Border>
                        </Grid>
                    </Grid>
                    
                    
                </Grid>
                
                <!--lend button-->
                <Grid Grid.Row="3" Visibility="{Binding LendEnable, Converter={StaticResource BoolToVisibilityConverter}}">
                    <Button Style="{StaticResource S_ButtonPicker}"                        
                        Command="{Binding LendCommand}"
                        attached:Images.NormalImage="/Resources/Images/emprestaae_oklend.png"
                        attached:Images.PressedImage="/Resources/Images/emprestaae_oklend_pressed.png">
                        <Grid>
                            <StackPanel Orientation="Horizontal"
                                    HorizontalAlignment="Right">                                
                                <TextBlock Style="{StaticResource S_TextBlockButtonPicker}"
                                       Text="pronto para emprestar!"
                                       Visibility="{Binding WhatImagePickered, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='Revert'}"/>
                            </StackPanel>
                        </Grid>
                    </Button>
                </Grid>
            </Grid>
        </Grid>
    </Grid>
</Page>